#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 1510;

int n;
int h[N], e[N], ne[N], idx;
int dp[N][2];
bool st[N];

void add(int a, int b)  // 添加一条边a->b
{
    e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void dfs(int u)
{
    dp[u][0] = 0, dp[u][1] = 1;
    for (int i = h[u]; i != -1; i = ne[i])
    {
        int j = e[i];
        dfs(j);
        // u结点不选 ｜ 所有u的子节点选
        dp[u][0] += dp[j][1];
        // u结点选 ｜ 所有u的子节点选不选 去一个最小值
        dp[u][1] += min(dp[j][0], dp[j][1]);
    }
}

int main()
{
    while (cin >> n)
    {
        memset(h, -1, sizeof h);
        idx = 0;
        
        memset(st, 0, sizeof st);
        
        for (int i = 0; i < n; i ++ )
        {
            int id, cnt;
            scanf("%d:(%d)", &id, &cnt);
            while (cnt -- )
            {
                int ver;
                cin >> ver;
                add(id, ver);
                st[ver] = true;
            }
        }
        int root = 0;
        while (st[root]) root ++ ;
        dfs(root);
        
        cout << min(dp[root][0], dp[root][1]) << endl;
    }
    return 0;
}
